import xlrd


class OnlineData:


    def online_data(self):
        return self.read_data(sheet_name='Sheet1')

    def online_data2(self):
        res = self.read_data(sheet_name='Sheet2')
        for e in res:
            e[5] = e[5].split(',')
        return res

    def online_not_bank_data(self):

        workBook = xlrd.open_workbook(filename='../TestData/test_onlineLoans_data.xls')
        sheet = workBook.sheet_by_name(sheet_name='Sheet3')
        arr = []
        for i in range(1, sheet.nrows):
            e = sheet.row_values(i)
            arr.append(e)

        return arr

    def online_big_money_data(self):
        return self.read_data(sheet_name='Sheet4')


    def online_small_money_data(self):
        return self.read_data(sheet_name='Sheet5')

    def online_not_time_data(self):
        return self.read_data(sheet_name='Sheet6')

    def online_time_data(self):
        return self.read_data(sheet_name='Sheet7')

    def read_data(self,sheet_name):
        workBook = xlrd.open_workbook(filename='../TestData/test_onlineLoans_data.xls')
        sheet = workBook.sheet_by_name(sheet_name=sheet_name)
        arr = []
        for i in range(1, sheet.nrows):
            e = sheet.row_values(i)
            e[4] = e[4].split(',')
            arr.append(e)
        return arr
